<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
	<title>查询药品信息列表</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content">
        <div class="box box-success">
            <div class="box-body">
                <div class="form-inline">
                     <div class="form-group form-group-xs">
                         	  药品编码：<input class="form-control" type="text" id="drugcode" placeholder="药品编码" />
                            </div>
                            <div class="form-group form-group-xs">
                                                                                      通用名： <input class="form-control" type="text" id="qualityspecName" placeholder="通用名" />
                   			</div>
                    <button type="button" onclick="likeQuery();" class="btn btn-success btn-sm">查询</button>
                </div>
            </div>
        </div>
        
         <table class="jqgrid col-sm-1" id="gridlistdrug"></table>
         <div id="gridpagedrug"></div>
		 <div class="box box-warning bottongroup">
            <button type="button" class="btn btn-primary btn-sm" onclick="batchGroupAddComp()">选&nbsp; 择</button>
            <button type="button" class="btn btn-danger btn-sm"   onclick="closeDiv()">取&nbsp; 消</button>
         </div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
        $(function () {
        	$("#gridlistdrug").jqGrid({
        	       url: "${ctx}/stdProdDrugInfo/getStdProdDrugInfoList.html",
        	       mtype: "POST",
        	       datatype: "json",
        	       postData:{"prodId":"${prodId}"},
        	       autowidth: true,
        	       height: 255,
        	       //shrinkToFit: false,
        	       colNames: ['id','药品编码',  '通用名', '剂型', '规格', '转换系数', '单位','材质', '生产企业'],
        	       colModel: [
        						{ name: 'prodId', width: 120 ,hidden:true,key:true, align:"center",sortable: false},
        						{ name: 'drugCode', width: 85 , align:"center",sortable: false},
        						{ name: 'qualityspecName', width: 60 , align:"center" ,sortable: false},
        						{ name: 'formName', width: 60 , align:"center" ,sortable: false},
        						{ name: 'specName', width: 70 , align:"center" ,sortable: false},
        						{ name: 'factor', width: 60 , align:"center" ,sortable: false},
        						{ name: 'unitName', width: 40 , align:"center" ,sortable: false},
        						{ name: 'materialName', width: 80 , align:"center" ,sortable: false},
        						{ name: 'compName', width: 150 , align:"center",sortable: false }
        	       ],
        	       rowNum: 10,
        	       rowList: [10, 20, 50,100],
        	       rownumbers: true,
        	       pager: "#gridpagedrug",
        	       //multiselect: true, 
        	       viewrecords: true,
        	       caption: "药品选择",
        	       jsonReader: {
        	           repeatitems: false,
        	           id: "ids"
        	       }
        	   });
        	   $("#gridlistdrug").jqGrid('navGrid', '#gridpagedrug', { add: false, edit: false, del: false, search: false, refresh: false });
        	   $(window).trigger("resize"); 
        });
     	function likeQuery() {
			var qualityspecName = $("#qualityspecName").val();
			var drugcode = $("#drugcode").val();
			$("#gridlistdrug").jqGrid('setGridParam',{
				       	    	datatype:'json',
				                postData:{
				                	"qualityspecName":qualityspecName,
									"drugCode":drugcode
				                	},
				                page : 1
			}).trigger("reloadGrid");
		}
    	
        function batchGroupAddComp(){
        	var prodId = $("#gridlistdrug").jqGrid('getGridParam', 'selrow');
        	if (prodId == null || prodId == ""){
        		$.HN.message.alert("请选择选定的产品！", "消息", "error");
        		return ;
        	}
    		 var rowdata = $("#gridlistdrug").jqGrid('getRowData', prodId);
    		 var dialog = top.dialog.get(window);
    		 var qualityspecName = rowdata.qualityspecName.replace('<span id="transmark"></span>','');
        	 dialog.close(rowdata.prodId+"|$"+qualityspecName+"|$${numberId}"); // 关闭（隐藏）对话框
        	 dialog.remove();				 // 主动销毁对话框
 			return false;
        }
        
        function closeDiv(){
        	var dialog = top.dialog.get(window);
        	 dialog.remove();	
        	 return false;
        }
    </script>
</body>
</html>